﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Metaspec;
using AbstraX.Contracts.Packages;

namespace CodeGenerationPipeline.PackageElements
{
    internal class PackageServiceType : IPackageServiceType
    {
        public Type ServiceType { get; set; }
        public CsClass ServiceClass { get; set; }

        public PackageServiceType(Type serviceType)
        {
            this.ServiceType = serviceType;
        }

        public PackageServiceType(CsClass serviceClass)
        {
            this.ServiceClass = serviceClass;
        }

        public string TypeFullName
        {
            get 
            {
                if (this.IsClass)
                {
                    return ServiceType.AssemblyQualifiedName;
                }
                else
                {
                    return ServiceClass.identifier.identifier;
                }
            }
        }

        public string TypeShortName
        {
            get 
            {
                if (this.IsClass)
                {
                    return ServiceType.Name;
                }
                else
                {
                    return ServiceClass.identifier.identifier;
                }
            }
        }

        public bool IsClass
        {
            get 
            {
                return ServiceClass != null;
            }
        }
    }
}
